package com.py.credit.service.impl;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.py.credit.dao.DissentAppealDao;
import com.py.credit.service.DissentAppealSeervice;
import com.py.framework.core.common.Page;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.CharsetUtil;
@Service
public class DissentAppealSeerviceImpl implements DissentAppealSeervice {
	@Autowired
	private DissentAppealDao dissentAppealDao;
	@Override
	public void addDissent(String ztmc, String sjlx, String sjly, String jbrxm, String jbrzjhm, String lxfs,
			String txdz, String description, String path,String tablename,String record_id,String key,String ssnr) {
		dissentAppealDao.addDissent(ztmc, sjlx, sjly, jbrxm, jbrzjhm, lxfs, txdz, description, path,tablename,record_id,key,ssnr);

	}
	@Override
	public List<Map<String,String>> getTableListForPage(String ztmc, String sjly, Page page) {
		List<Map<String,String>> data = dissentAppealDao.getTableListForPage(ztmc,sjly,page);
		for(Map<String,String> map : data) {
			for (Entry<String, String> vo : map.entrySet()) {
				if(vo.getKey().equals("jbrzjhm")) {
					String str1 = map.get(vo.getKey()).substring(0,10);
					String str2 = map.get(vo.getKey()).substring(14,18);
					map.put(vo.getKey(), str1+"****"+str2);
				}				
			}
		}
		return data;
	}
	@Override
	public void DissentHandle(String id, String cljg, String clyj, String status,String deptName,String olddata,Long deptId,Long userId) {
		dissentAppealDao.DissentHandle(id,cljg,clyj,status,deptName,olddata,deptId,userId);
		
	}
	@Override
	public List<Map<String, String>> selectBaseData(String record_id, String tablename) {
		tablename = tablename.substring(2,tablename.length());
		return dissentAppealDao.selectBaseData(record_id,tablename);
	}
	@Override
	public List<Map<String, Object>> getHistoryTableListForPage(String ztmc, String sjly, String cljg, Page page, Long deptId, Long userId) {
		return dissentAppealDao.getHistoryTableListForPage(ztmc,sjly,cljg,page,deptId,userId);
	}
	@Override
	public void deleteBaseData(String record_id, String tablename) {
		dissentAppealDao.deleteBaseData(record_id,tablename);
		
	}
	@Override
	public List<Map<String, Object>> getdata(String record_id, String tablename,String ztmc,String cloumn) {
		return dissentAppealDao.getdata(record_id,tablename,ztmc,cloumn);
	}
	@Transactional
	@Override
	public void executeDynamicSql(String sql) {
		dissentAppealDao.executeDynamicSql(sql);
		
	}
	@Override
	public Map<String, String> gettableId(String resource_id,String record_id,String tablename) {
		
		return 	dissentAppealDao.gettableId(resource_id,record_id,tablename);
	}
	@Override
	public Map<String, String> getmapHei(String record_id, String tablename) {
	
		return dissentAppealDao.getmapHei(record_id,tablename);
	}
	@Override
	public Map<String, String> getmapcf(String record_id, String tablename) {
		return dissentAppealDao.getmapcf(record_id,tablename);
	}
	@Override
	public List<Map<String, String>> getProcessForPage(String cxm,Page page) {
		return dissentAppealDao.getProcessForPage(cxm,page);
	}
	@Transactional
	@Override
	public void updateStatus(String id, String status,String newdata,String memetric) {
		 dissentAppealDao.updateStatus(id,status,newdata,memetric);
		
	}
	
	
	@Override
	public List<Map<String, String>> getsupervisionResultListForPage(String ztmc, String tybm, String type, Page page) {
		
		return dissentAppealDao.getsupervisionResultListForPage(ztmc,tybm,type,page);
	}
	
	
	@Override
	public List<Map<String, String>> supervisionResultDetail(String ztmc) {
		
		return dissentAppealDao.supervisionResultDetail(ztmc);
	}

}
